package com.zhouhailin.fastjsondemo;

import com.alibaba.fastjson.JSONObject;

/**
 * 将JSON格式的字符串，转为JSON字符串对象
 *
 * @Author：zhouhailin
 * @Date： 2023/3/14
 */
public class FastJsonDemo {
    public static void main(String[] args) {
        // JSON格式的字符串
        String jsonStr = "{\"requestHash\":\"7fa397c593ca53ddeb03de73d71a3bcea47b8072268fd1230dccc2519f628a28\",\"wayBillNo\":\"202205120001326\",\"recordNo\":\"32rYEAvygqzZ6Mr8j4bY72Fzxi6GvajX\"}";
        // 转为JSON字符串对象
        JSONObject jsonObject = JSONObject.parseObject(jsonStr);

        // 根据JSON字符串对象的key获取value值
        String requestHash = jsonObject.get("requestHash").toString();
        System.out.println("Hash值：" + requestHash);

        String wayBillNo = jsonObject.get("wayBillNo").toString();
        System.out.println("号码：" + wayBillNo);
    }
}
